package com.example.xm.adapter.DiscoverAdapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.example.xm.R;
import com.example.xm.base.BaseAdapter;
import com.example.xm.bean.DiscoverBean.DiscoverReMenBean;
import com.example.xm.utiles.SystemUtils;

import java.util.List;

import butterknife.BindView;

public class DiscoverReMenAdapter extends BaseAdapter {


    public DiscoverReMenAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected int getLayout() {
        return R.layout.adapter_discover_remen;
    }

    @Override
    protected void bindData(BaseViewHolder viewHolder, Object o) {
        ImageView img = (ImageView) viewHolder.getViewById(R.id.iv_img);
        TextView title = (TextView) viewHolder.getViewById(R.id.tv_title_discover_remen);
        TextView dizhi = (TextView) viewHolder.getViewById(R.id.tv_dizhi_discover_remen);
        TextView date = (TextView) viewHolder.getViewById(R.id.tv_data_discover_remen);
        DiscoverReMenBean.DataBean bean = (DiscoverReMenBean.DataBean) o;
        int i = SystemUtils.px2Dp(context, 60);
        RoundedCorners roundedCorners = new RoundedCorners(i);
        RequestOptions requestOptions = RequestOptions.bitmapTransform(roundedCorners);
        Glide.with(context).load(bean.getCover()).apply(requestOptions).into(img);
        title.setText(bean.getTitle());
        dizhi.setText(bean.getLocation());
        date.setText(bean.getCreateTime());
    }
}
